package com.fs.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fs.mapper.OrderGoodsMapper;
import com.fs.pojo.OrderGoods;
import com.fs.vo.PageResult;
import com.fs.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class OrderGoodsServiceImpl implements OrderGoodsService{

    @Autowired
    private OrderGoodsMapper orderGoodsMapper;

    @Override
    public PageResult getList(PageResult pageResult) {
        boolean flag = StringUtils.hasLength(pageResult.getQuery());
        QueryWrapper<OrderGoods> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(flag,"username",pageResult.getQuery()).orderByDesc("id");
        Page<OrderGoods> page = new Page<>(pageResult.getPageNum(), pageResult.getPageSize());
        Page<OrderGoods> e = orderGoodsMapper.selectPage(page, queryWrapper);
        return pageResult.setTotal(e.getTotal()).setRows(e.getRecords());
    }
}
